From 0fc13df6b8cacc09bc25660915ff3fb716535d0a Mon Sep 17 00:00:00 2001 From: Mathieu Gagne Date: Tue, 17 Apr 2012 19:13:52 +0100 Subject: [PATCH] xl: xl network-attach -N (dry run) option Add dryrun for testing and debugging purposes. Signed-off-by: Mathieu Gagne Acked-by: Ian Campbell Acked-by: Stefano Stabellini --- tools/libxl/xl_cmdimpl.c | 10 ++++++++++ tools/libxl/xl_cmdtable.c | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index 4febe25cb6..5703512d24 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -4916,6 +4916,16 @@ int main_networkattach(int argc, char **argv) return 1; } } + + if (dryrun_only) { + char *json = libxl_device_nic_to_json(ctx, &nic); + printf("vif: %s\n", json); + free(json); + libxl_device_nic_dispose(&nic); + if (ferror(stdout) || fflush(stdout)) { perror("stdout"); exit(-1); } + return 0; + } + if (libxl_device_nic_add(ctx, domid, &nic)) { fprintf(stderr, "libxl_device_nic_add failed.\n"); return 1; diff --git a/tools/libxl/xl_cmdtable.c b/tools/libxl/xl_cmdtable.c index f461a2a1b5..736a8366ed 100644 --- a/tools/libxl/xl_cmdtable.c +++ b/tools/libxl/xl_cmdtable.c @@ -288,7 +288,7 @@ struct cmd_spec cmd_table[] = { "", }, { "network-attach", - &main_networkattach, 0, + &main_networkattach, 1, "Create a new virtual network device", " [type=] [mac=] [bridge=] " "[ip=] [script=